﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace LotteryAdmin.Controls
{
    public partial class OnlineStatusControl : UserControl
    {
        public static readonly DependencyProperty OnlineStatusProperty = DependencyProperty.Register("OnlineStatus", typeof(short), typeof(OnlineStatusControl), new PropertyMetadata(new PropertyChangedCallback(OnOnlineStatusChanged)));
        public OnlineStatusControl()
        {
            InitializeComponent();
        }
        private static void OnOnlineStatusChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            (d as OnlineStatusControl).SetOnlineStatus((short)e.NewValue);
        }

        public void SetOnlineStatus(short onlinestatus)
        {
            if (onlinestatus == 1)
            {
                this.LightGradientStop.Color=Color.FromArgb(0xff, 0, 0xff, 0);
                this.InGradientStop.Color=Colors.Green;
                this.Storyboard_Light.Begin();
            }
            else if (onlinestatus == 0)
            {
                this.LightGradientStop.Color = Colors.White;
                this.InGradientStop.Color = Colors.Gray;
                this.Storyboard_Light.Stop();
            }
            else
            {
                LayoutRoot.Visibility = Visibility.Collapsed;
            }
        }

        public short OnlineStatus
        {
            get
            {
                return (short)GetValue(OnlineStatusProperty);
            }
            set
            {
                SetValue(OnlineStatusProperty, value);
            }
        }
    }
}
